import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core';
import { StudentService } from './student.service';
// import { test1 } from './bean';
//装饰器写法
@Component({
  selector: 'app-student',
  templateUrl: './student.component.html',
  styleUrls: ['./student.component.css'],
  providers: [StudentService]
})
export class StudentComponent implements OnInit {
  constructor(private student: StudentService) {
    console.log(this.student.studentList);
  }
  ngOnInit() {}

  callFun(evt: any) {
    console.log('son is ' + evt);
  }

  @Output() voted = new EventEmitter();
  @Input() aChild;
  @Input() bChild;
  dian(evt: any) {
    //alert(evt.currentTarget.id);
    let ew = evt.currentTarget.id;
    this.voted.emit(ew);
  }

  //@Output() voted = new EventEmitter();
  dianSon(evt: any) {
    let ew = evt.currentTarget.id;
    this.voted.emit(ew);
  }

  ngOnChanges(e) {
    for (let key in e) {
      if (e[key].isFirstChange()) {
        console.log(key + '=' + e[key].currentValue);
      } else {
        console.log(key + '=' + e[key].previousValue);
      }
    }
  }
}
